/*------------------------------------------------------------------------------

Publication: Schakel, W. (2020) Representing the Rich: Economic and Political
	Inequality in Established Democracies. University of Amsterdam: Doctoral
	Dissertation.

Chapter: 5

Description: This do-file produces Figure 5.1 and performs small analyses of
	party and union membership reported in footnotes of chapter 5.

Sections:

	1. Figure 5.1 (support for increasing the retirement age by income)
	2. Party membership by income
	3. Union membership over time

Data: Dutch Parliamentary Election Study of 2012, downloaded in May 2019 from:
	https://doi.org/10.17026/dans-x5h-akds

	Dutch Parliamentary Election Study of 1971, downloaded in May 2019 from:
	https://doi.org/10.17026/dans-x3j-3a4m

	LISS panel data, downloaded in May 2019 from:
	https://www.dataarchive.lissdata.nl

------------------------------------------------------------------------------*/

global data	"YOUR PATH HERE"

/*------------------------------------------------------------------------------
 1. Figure 5.1 (support for increasing the retirement age by income)
------------------------------------------------------------------------------*/

* I downloaded the 2012 Dutch Parliamentary Election Study from the link
* provided above and converted it from SPSS to Stata.
use "$data\NKO2012.dta", clear

recode V359 V344 (99/max=.), gen(inc edu)
recode V341 (995=.), gen(gender)
recode V210 (2=0), gen(vote)
gen weight=Wgt1c
recode V140 (1 2=1) (3 4=0) (99/max=.), gen(q771)

egen inctot=count(inc)
gen incm=.
sum inc

* Here I transform the income variable in the same way as in chapter 3.
forval b=1/`r(max)' {
	egen incn`b'=count(inc) if inc==`b'
	sum incn`b'
	replace incn`b'=`r(mean)'
	egen incc`b'=rowtotal(incn*)
	}

rename incc# incc#, renumber(2)
gen incc1=0
sum inc

forval c=1/`r(max)' {
	gen incm`c'=(incc`c' + (incn`c'/2))/inctot
	replace incm=incm`c' if inc==`c'
	}

reg q771 c.incm##c.incm [pw=weight]
quietly margins, at(incm=(.05(.01).95))
marginsplot, recast(line) plotop(lc(gs0) lw(medthick))						///
	recastci(rline) ciop(lp(dash) lc(gs0))									///
	xlab(0(.2)1 .2 "20" .4 "40" .6 "60" .8 "80" 1 "100")					///
	ylab(0(.2)1 .2 "20" .4 "40" .6 "60" .8 "80" 1 "100", ang(hor) nogrid)	///
	xtitle("Income percentile", m(0 0 0 2))	scale(1.1)						///
	ytitle("Percent in favor", m(zero)) legend(off) yline(.5, lc(gs12))		///
	plotr(m(zero) lc(white)) graphr(m(2 4 2 3) fc(white) lc(white)) title("")

drop inc-incm10

* In a footnote associated with Figure 5.1, I note that support for increasing
* the retirement age is higher for the very lowest income group. I look into
* the reasons behind it here.
use "$data\NKO 2012.dta", clear

recode V140 (1 2=1) (3 4=0) (99/max=.), gen(ret)
recode V359 V344 (99/max=.), gen(inc edu)
recode V345 (1/4=0) (5=1) (999=.), gen(highedu)
recode V340 (min/29=1) (30/max=0), gen(young)

table inc, c(mean young mean highedu)
table young if inc==1 & V340!=30, c(mean ret n ret)

/*------------------------------------------------------------------------------
 2. Party membership by income 
------------------------------------------------------------------------------*/

/* From the LISS data archive, I downloaded net household income (nettohh_f),
along with the annual variables on party membership (cv08a098, cv09b098,
cv10c098, cv11d098, cv12e098, cv13f098, cv14g098, cv016h098, cv17i098, cv18j098
and cv19k098). The data set automatically includes respondents' ID (nomem_encr)
and wave ID (wave). */

use "$data\LISS_party.dta", clear

gen pmem=.

foreach i in 08 09 10 11 12 13 14 16 17 18 19 {
	replace pmem=cv`i' if wave==20`i'01
	}

rename nomem_encr id
replace wave=(wave/100)-2000.01
drop cv*

reshape wide pmem nettohh_f, i(id) j(wave)
order pmem* nettohh_f*, after(id)

forval i=9/19 {
	xtile inc`i'=nettohh_f`i', n(100)
	}

egen inc=rowmean(inc9-inc19)

egen pmem=rowmean(pmem8-pmem19)
recode pmem (2=0) (1/1.99=1)

drop netto*

pwcorr inc pmem, obs sig

/*------------------------------------------------------------------------------
 3. Union membership over time 
------------------------------------------------------------------------------*/

* First I calculate the correlation between income, education and union
* membership in 1971. For the Dutch Parliamentary Election Study of this year,
* I downloaded the .por file from the link provided above, opened it in SPSS and
* saved it as a Stata file.
use "$data\NKO1971.dta", clear

* If only other members of the household are union members and not the
* respondent themselves, I exclude them from the variable.
recode var350 (2=0) (8 9=.), gen(union)
replace union=0 if var351==3 | var351==4

gen inc=var372 if var372<12

* Education is coded in a very detailed way, up to four digits. I round the
* values to one digit, since one cannot clearly distinguish low and high
* education levels beyond that.
gen edu=var313 if var313!=9999
replace edu=round(edu/100,1) if edu<100
replace edu=round(edu/1000,1) if edu>1000

pwcorr union inc edu, obs sig

* 2012
use "$data\NKO2012.dta", clear

recode V262 (2=0), gen(union)
gen inc=V359 if V359<11
gen edu=V344 if V344<999

pwcorr union inc edu, obs sig
